package com.dotto.atos.fragments;

import java.util.List;
import java.util.Vector;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.dotto.atos.R;
import com.dotto.atos.ui.PagerAdapter;
import com.dotto.atos.utils.MessageUtil;

public class ReportFragment extends Fragment {
	public static final String TAG = "ReportFragment";
	private View fragmentView;
	private Activity mActivity;
	@SuppressWarnings("unused")
	private ReportFragment instance;

	@SuppressWarnings("unused")
	private MessageUtil messageUtil;

	private List<Fragment> fragments;
	private ViewPager viewPager;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		if (fragmentView == null) {
			fragmentView = inflater.inflate(R.layout.fragment_reports,
					container, false);
		} else {
			((ViewGroup) fragmentView.getParent()).removeView(fragmentView);
		}
		mActivity = this.getActivity();
		instance = this;
		messageUtil = new MessageUtil(mActivity);
		initView();
		return fragmentView;
	}

	public void initView() {
		if (fragmentView != null) {

			if (fragments == null) {
				fragments = new Vector<Fragment>();
				fragments.add(Fragment.instantiate(mActivity,
						ImageViewFragment.class.getName()));
				fragments.add(Fragment.instantiate(mActivity,
						ImageViewFragment.class.getName()));
				fragments.add(Fragment.instantiate(mActivity,
						ImageViewFragment.class.getName()));
				PagerAdapter mPagerAdapter = new PagerAdapter(
						getFragmentManager(), fragments);
				viewPager = (ViewPager) fragmentView
						.findViewById(R.id.viewpager);
				viewPager.setAdapter(mPagerAdapter);
			}
		}
	}
}
